
#pragma once

#include "zen_vap.h"

#include "MyConfig.h"
#include "LabelsLayer.h"
#include "ParticleLayer.h"
#include "SpritesLayer.h"
#include "BGLayer.h"
#include "FiguresLayer.h"
#include "MySprite.h"

using namespace Zen;
using namespace Zen::Vap;

class RootScene2d : public Combination2D
{
protected:
	std::weak_ptr<LabelsLayer> m_labels;
	std::weak_ptr<BGLayer> m_BG;
public:
	RootScene2d()
	{
	}
	void load() override
	{
		auto vs = Activity::Get()->getRealViewSize();

		// bg
		this->addNode(std::make_shared<BGLayer>());

		// sprites.
		this->addNode(std::make_shared<SpritesLayer>());

		// particle
		{
			auto par = std::make_shared<ParLayer>();
			par->setY(vs.h*0.7);
			par->setScale(0.5f, 1.5f);
			this->addNode(par);
		}
		{
			auto par = std::make_shared<ParLayer>();
			par->setY(vs.h*0.3); //(0, 500);
			par->setScale(0.5f, 0.5f);
			this->addNode(par);

		}
		// figure
		this->addNode(std::make_shared<FiguresLayer>());

		/// label
		auto label = std::make_shared<LabelsLayer>();
		this->addNode(label);
		m_labels = label;
	}
	void setFPS(float fps)
	{
#if ZEN_DRAW_METAL
		std::string s = "metal " + std::to_string(fps);
#else
		std::string s = "opengl " + std::to_string(fps);
#endif
		if(!m_labels.expired()) m_labels.lock()->setFPSText(s);
	}

	Node * onTouchDown(const AppTouch &touch) {
		cout << __func__ << touch.no << " " << touch.x << " " << touch.y << endl;
		return this;
	}
};
